//
//  NSWelcomeViewController.m
//  Meboo
//
//  Created by kyo on 2024/3/20.
//

#import "NSWelcomeViewController.h"
#import "KLLoginViewController.h"
#import "Meboo-Swift.h"
@interface NSWelcomeViewController ()
@property(nonatomic,strong) MBLottieView *animationView;
@end

@implementation NSWelcomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
}

- (void)resetRootView {
    AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
    if ([MBUserAccount defaultAccount].token) {
        appDelegate.window.rootViewController = [[BaseTabBarViewController alloc]init];
    } else {
        appDelegate.window.rootViewController = [[BaseNavViewController alloc] initWithRootViewController:[[KLLoginViewController alloc]init]];
    }
}

#pragma mark - UI
- (void)setupUI {
    [self.view addSubview:self.animationView];
    [self.animationView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    __WeakSelf
    [self.animationView layoutIfNeeded];
    [self.animationView showWithName:@"launchVideo.json" loop:NO finishState:YES completionBlock:^(BOOL animationFinished) {
        if (animationFinished) {
            [weakSelf resetRootView];
        }
    }];
}

#pragma mark - Setter && Getter
- (MBLottieView *)animationView {
    if (!_animationView) {
        _animationView = [MBLottieView new];
    }
    return _animationView;
}

@end
